/*     */ package andriod.service;
/*     */ 
/*     */ import andriod.dao.PersistDao;
/*     */ import com.jcrj.entity.OFlowForm;
/*     */ import com.jcrj.entity.OUser;
/*     */ import com.jcrj.util.FielAll;
/*     */ import java.math.BigDecimal;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ 
/*     */ public class ArdFlowService
/*     */ {
/*     */   private PersistDao persistDao;
/*     */ 
/*     */   public List<FielAll> getWorkFlowTaskfile(String process, OUser user)
/*     */   {
/*  20 */     List faList = new ArrayList();
/*  21 */     StringBuffer sql = new StringBuffer();
/*  22 */     String hql = "from OFlowForm";
/*  23 */     List oflowform = this.persistDao.find(hql);
/*  24 */     sql
/*  25 */       .append("select id,unit,time,title,userid,flowid,null,flow,INSTANCEID,reject_s  from (");
/*  26 */     for (int i = 0; i < oflowform.size(); i++) {
/*  27 */       OFlowForm ff = (OFlowForm)oflowform.get(i);
/*  28 */       if (user == null)
/*  29 */         sql
/*  30 */           .append(" select id,null as unit,to_date(createtime,'yyyy-mm-dd') as time,null as title,TO_CHAR(USERID) as userid,flowid,null,flowid as flow,INSTANCEID,reject_s from " + 
/*  31 */           ff.getTableName() + 
/*  32 */           " where instanceId in(" + 
/*  33 */           process + ") ");
/*     */       else {
/*  35 */         sql
/*  36 */           .append("  select id,null as unit,to_date(createtime,'yyyy-mm-dd') as time,null as title,TO_CHAR(USERID) as userid,flowid,null,flowid as flow,INSTANCEID,reject_s from " + 
/*  37 */           ff.getTableName() + 
/*  38 */           " where  reject='true' and instanceId is null and userId =" + 
/*  39 */           user.getId() + 
/*  40 */           " or reject='true' and instanceId in(" + 
/*  41 */           process + ")");
/*     */       }
/*  43 */       if (i != oflowform.size() - 1) {
/*  44 */         sql.append(" union all ");
/*     */       }
/*     */     }
/*  47 */     sql.append(" ) t ");
/*  48 */     sql.append(" order by t.time desc");
/*  49 */     List<Object[]> listob = this.persistDao.query(sql.toString());
/*  50 */     for (Object[] obj : listob) {
/*  51 */       FielAll fa = new FielAll();
/*  52 */       fa.setId(Integer.valueOf(((BigDecimal)obj[0]).intValue()));
/*  53 */       fa.setUnit((String)obj[1]);
/*  54 */       fa.setTime((Date)obj[2]);
/*  55 */       fa.setTitle((String)obj[3]);
/*  56 */       fa.setSender((String)obj[4]);
/*  57 */       fa.setFielTyoe((String)obj[5]);
/*  58 */       fa.setSort((String)obj[6]);
/*  59 */       fa.setFlow((String)obj[7]);
/*  60 */       fa.setEndTime(obj[8] == null ? "1" : 
/*  61 */         ((BigDecimal)obj[8]).toString());
/*  62 */       fa.setReject((String)obj[9]);
/*  63 */       faList.add(fa);
/*     */     }
/*  65 */     return faList;
/*     */   }
/*     */ 
/*     */   public Long countWorkFlowTaskFile(String process, OUser user)
/*     */   {
/*  70 */     Long count = Long.valueOf(0L);
/*  71 */     StringBuffer sql = new StringBuffer();
/*  72 */     String hql = "from OFlowForm";
/*  73 */     List oflowform = this.persistDao.find(hql);
/*  74 */     if ((oflowform != null) && (!oflowform.isEmpty())) {
/*  75 */       sql.append("select count(t.id) from (");
/*  76 */       for (int i = 0; i < oflowform.size(); i++) {
/*  77 */         OFlowForm ff = (OFlowForm)oflowform.get(i);
/*  78 */         if (user == null)
/*  79 */           sql
/*  80 */             .append("select id,null as title,to_date(createtime,'yyyy-mm-dd') as time from " + 
/*  81 */             ff.getTableName() + 
/*  82 */             " where instanceId in(" + process + ") ");
/*     */         else {
/*  84 */           sql
/*  85 */             .append("select id,null as title,to_date(createtime,'yyyy-mm-dd') as time from " + 
/*  86 */             ff.getTableName() + 
/*  87 */             " where  reject='true' and instanceId is null and userId =" + 
/*  88 */             user.getId() + 
/*  89 */             " or reject='true' and instanceId in(" + 
/*  90 */             process + ")");
/*     */         }
/*  92 */         if (i != oflowform.size() - 1) {
/*  93 */           sql.append(" union all ");
/*     */         }
/*     */       }
/*  96 */       sql.append(" ) t");
/*  97 */       count = Long.valueOf(this.persistDao.queryForLong(sql.toString()));
/*     */     }
/*  99 */     return count;
/*     */   }
/*     */ 
/*     */   public PersistDao getPersistDao() {
/* 103 */     return this.persistDao;
/*     */   }
/*     */ 
/*     */   public void setPersistDao(PersistDao persistDao) {
/* 107 */     this.persistDao = persistDao;
/*     */   }
/*     */ }

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     andriod.service.ArdFlowService
 * JD-Core Version:    0.6.0
 */